// 引入 request 方法，假设 request 方法已经定义在某个工具文件中
import request from '/@/utils/request';
import {
    AddUserInput,
    BaseIdInput,
    ChangePwdInput,
    DeleteUserInput,
    SysUser,
    PageUserInput,
    UpdateUserInput,
    UserRoleInput,
    ResetPwdUserInput,
    UnlockLoginInput,
    UserInput
} from '../models';
// 定义 API 路径枚举
enum Api {
    SysUserAdd = '/sysUser/add',
    SysUserBaseInfo = '/sysUser/baseInfo',
    SysUserChangePwd = '/sysUser/changePwd',
    SysUserDelete = '/sysUser/delete',
    SysUserGrantRole = '/sysUser/grantRole',
    SysUserOwnExtOrgList = '/sysUser/ownExtOrgList/{userId}',
    SysUserOwnRoleList = '/sysUser/ownRoleList/{userId}',
    SysUserPage = '/sysUser/page',
    SysUserResetPwd = '/sysUser/resetPwd',
    SysUserSetStatus = '/sysUser/setStatus',
    SysUserUnlockLogin = '/sysUser/unlockLogin',
    SysUserUpdate = '/sysUser/update',
}

// 定义 API 方法
export const apiSysUserAddPost = (body?: AddUserInput) =>
    request({
        url: Api.SysUserAdd,
        method: 'post',
        data: body,
    });

export const apiSysUserBaseInfoGet = () =>
    request({
        url: Api.SysUserBaseInfo,
        method: 'get',
    });

export const apiSysUserBaseInfoPost = (body?: SysUser) =>
    request({
        url: Api.SysUserBaseInfo,
        method: 'post',
        data: body,
    });

export const apiSysUserChangePwdPost = (body?: ChangePwdInput) =>
    request({
        url: Api.SysUserChangePwd,
        method: 'post',
        data: body,
    });

export const apiSysUserDeletePost = (body?: DeleteUserInput) =>
    request({
        url: Api.SysUserDelete,
        method: 'post',
        data: body,
    });

export const apiSysUserGrantRolePost = (body?: UserRoleInput) =>
    request({
        url: Api.SysUserGrantRole,
        method: 'post',
        data: body,
    });

export const apiSysUserOwnExtOrgListUserIdGet = (userId: number) =>
    request({
        url: Api.SysUserOwnExtOrgList.replace('{userId}', String(userId)),
        method: 'get',
    });

export const apiSysUserOwnRoleListUserIdGet = (userId: number) =>
    request({
        url: Api.SysUserOwnRoleList.replace('{userId}', String(userId)),
        method: 'get',
    });

export const apiSysUserPagePost = (body?: PageUserInput) =>
    request({
        url: Api.SysUserPage,
        method: 'post',
        data: body,
    });

export const apiSysUserResetPwdPost = (body?: ResetPwdUserInput) =>
    request({
        url: Api.SysUserResetPwd,
        method: 'post',
        data: body,
    });

export const apiSysUserSetStatusPost = (body?: UserInput) =>
    request({
        url: Api.SysUserSetStatus,
        method: 'post',
        data: body,
    });

export const apiSysUserUnlockLoginPost = (body?: UnlockLoginInput) =>
    request({
        url: Api.SysUserUnlockLogin,
        method: 'post',
        data: body,
    });

export const apiSysUserUpdatePost = (body?: UpdateUserInput) =>
    request({
        url: Api.SysUserUpdate,
        method: 'post',
        data: body,
    });